/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1687614873038_464';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  // 配置安全验证
  config.security = {
    csrf: {
      ignore: () => {
        return true;
      },
    },
    // 将域名加入白名单
    // domainWhiteList: [ 'http://localhost:8080' ],
  };

  // config/config.default.js
  // 配置允许跨域
  config.cors = {
    // 任何地址都可以访问
    origin: '*',
    // 指定地址才可以访问
    // origin: 'http://localhost:8080',
    allowMethods: 'GET,PUT,POST,DELETE',
    // cookie跨域配置
    credentials: true,
  };

  config.mysql = {
    client: {
      // host
      host: '39.101.184.236',
      // 端口号
      port: '3306',
      // 用户名
      user: 'foo',
      // 密码
      password: 'bar',
      // 数据库名
      database: 'beermaster',
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  config.jwt = {
    secret: 'beermaster',
  };

  return {
    ...config,
    ...userConfig,
  };
};
